const { mysql: config } = require('../config')
const { mysql } = require('../qcloud')

module.exports = async (ctx) => {
  const { isbn } = ctx.request.query
  const DB = mysql
    // const DB = require('knex')({
    //   client: 'mysql',
    //   connection: {
    //     host: config.host,
    //     port: config.port,
    //     user: config.user,
    //     password: config.pass,
    //     database: config.db,
    //     charset: config.char,
    //     multipleStatements: true
    //   }
		// })
		// select id, title, image, count from books order by count desc limit 9;
		const banner = await DB('books')
										.select('id', 'isbn', 'title', 'image', 'count')
										.orderBy('count', 'desc')
										.limit(9)
		ctx.state.data = {
			banner
		}
}
